import Vue from 'vue'
import VueRouter from 'vue-router'

// 导入组件
import layout from '@/views/layout'
import login from '@/views/login'
import register from '@/views/register'
import detail from '@/views/detail'
import article from '@/views/article'
import collect from '@/views/collect'
import like from '@/views/like'
import user from '@/views/user'
Vue.use(VueRouter)

// 设置规则
const routes = [
  {
    name: 'MjLayout',
    path: '/',
    component: layout,
    children: [
      { name: 'article', path: 'article', component: article },
      { name: 'collect', path: 'collect', component: collect },
      { name: 'like', path: 'like', component: like },
      { name: 'user', path: 'user', component: user }
    ]
  },
  { name: 'MjLogin', path: '/login', component: login },
  { name: 'MjReg', path: '/register', component: register },
  { name: 'MjDetail', path: '/detail', component: detail }
]

const router = new VueRouter({
  routes
})

export default router
